package com.itheima.publisher;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;

/**
 * @Author: fanYuLe
 * @CreateTime: 2025-03-31  15:51
 * @Description:
 */
@Slf4j
@AllArgsConstructor
@Configuration
public class MqConfig {
    private final RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setReturnsCallback(returned -> {
            log.error("触发return callback");
            log.error("exchange:{}",returned.getExchange());
            log.error("routingKey:{}",returned.getRoutingKey());
            log.error("message:{}",returned.getMessage());
            log.error("replyCode:{}",returned.getReplyCode());
            log.error("replyText:{}",returned.getReplyText());
        });
    }
}
